import java.util.HashMap;
import java.util.Map;

/**
 * 
 */

/**
 * @author Paola
 *This is an utility class that calculate for each resource 
 *the percentage (wrt all the concepts) of concepts present for each language
 *
 *
 *
 */
public class PercentageForLanguage {
	 private HashMap<String,Double> Percentlang;
	 
	 
	 
	 
	 public PercentageForLanguage()
	  {
		 Percentlang = new HashMap<String,Double>();
		  for (String l : LanguageTags.getAllISOLangTag()) {

			  Percentlang.put(l,0.0);
		  }
		  

	  }
	 
	 public PercentageForLanguage(ConceptsForLanguage cl, Double ctot)
	  {
		double perc=0.0;
		 Percentlang = new HashMap<String,Double>();
		  for (String l : LanguageTags.getAllISOLangTag()) {

			  Percentlang.put(l,0.0);
		  }
		
		  
			  for (Map.Entry<String, Integer> entry : cl.getValuelang().entrySet()) {
			  
			  
			  perc= ((100*entry.getValue())/ctot);
			  Percentlang.put(entry.getKey(), perc);
		  }

	  }
	 
	 
	 
	 
	  public Double getNumberConceptsforLanguage(String hashkey)
	  {
	  	return Percentlang.get(hashkey);
	  	
	  }
	  
	  public void setNumberConceptsforLanguage(String hashkey, Double d)
	  {
		  Percentlang.put(hashkey, d);
	  	
	  }
	  
	  public String[] keyToStringArray()
	  {
		  String [] aux=new String[Percentlang.size()];
		  int i=0;
		  //iterating over keys only
		  for (String key : Percentlang.keySet()) {
			  aux[i]=key;
			  i++;
		  }
		  
		  return aux;
	  }
	  
	  public String[] valueToStringArray()
	  {
		  String[] aux=new String[Percentlang.size()];
		  int i=0;
		  //iterating over values only
		  for (Double key : Percentlang.values()) {
			  aux[i]=key.toString();
			  i++;
		  }
		  
		  return aux;
	  }


	  
	 

}
